<template>
  <div class="login-view">
    <span>用户名：</span>
    <input type="text" v-model="loginUser.userName"> <br><br>
    <span>密码：</span>
    <input type="text" v-model="loginUser.password"> <br><br>
    <button @click="add">登录</button>
    <button @click="reset">重置</button>
  </div>
</template>

<script>
export default {
  name:"LoginView",
  data(){
    return {
      loginUser:{
        userName:"",
        password:""
      }
    }
  },
  methods:{
    add(){
      // 假设 用户名 admin 密码 123456  
      if(this.loginUser.userName == "admin"){
        if(this.loginUser.password == "123456"){
          this.$router.push("/home")
        }else{
          alert("用户名与密码不匹配")
        }
      }else{
        alert("该用户名不存在")
      }

    },
    reset(){
      this.loginUser = {
        userName:"",
        password:""
      }
    }
  }
}
</script>

<style scoped>

</style>